package com.alks.function.service.impl.pcfactorywork;

import com.alks.common.data.dto.SysUserTokenDTO;
import com.alks.common.data.thread.UserIdThread;
import com.alks.common.utils.FieldUtils;
import com.alks.common.utils.beanutils.ArrayUtils;
import com.alks.common.utils.beanutils.BeanUtil;
import com.alks.common.utils.beanutils.StringUtils;
import com.alks.entity.data.entity.*;
import com.alks.entity.data.page.PageRecord;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.entity.exception.ServiceErrorException;
import com.alks.function.data.dto.pcfactorywork.*;
import com.alks.function.data.request.factorywork.*;
import com.alks.function.mapper.SdStyleColorPhotoMapper;
import com.alks.function.mapper.pcfactorywork.*;
import com.alks.function.mapper.stockdept.pcfactorystockquery.SD_SQ_SdBomPartNew2Mapper;
import com.alks.function.service.pcfactorywork.IPcSupplementService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import static com.alks.entity.data.enums.ResultCodeEnum.DATA_IS_ERR;
import static com.alks.entity.data.enums.ResultCodeEnum.LOGIN_CONFIG_IS_NULL;

/**
 * <p>
 * 补料总表 服务实现类
 * </p>
 *
 * @author ms
 * @since 2023-07-19
 */
@Service
@Slf4j
@RequiredArgsConstructor
public class PcSupplementServiceImpl extends ServiceImpl<PcSupplementHeadMapper, PcSupplementHead> implements IPcSupplementService {
    private final PcSupplementHeadMapper headMapper;
    private final PcSupplementDetailMapper detailMapper;
    private final PcSupplementMtlMapper mtlMapper;
    private final PcSupplementMtlLotMapper lotMapper;
    private final PcSupplementDutyMapper dutyMapper;
    private final SdStyleColorPhotoMapper photoMapper;
    private final SD_SQ_SdBomPartNew2Mapper partNew2Mapper;

    private final String PassCompanyName = "丁总";

    @Override
    public ResponseInfo listSupplementHead(PcSupplementHeadRequest request) {
        /*分页初始化*/
        if (request.getPageNum() == null || request.getPageSize() == null) {
            request.setPageNum(1);
            request.setPageSize(10);
        }
        /*查询数据*/
        String userName = UserIdThread.get().getUserName();
        PageHelper.startPage(request.getPageNum(), request.getPageSize());
        List<PcSupplementHeadDto> record = headMapper.listSupplementHead(request, userName, UserIdThread.get().getCompanyId());
        Page<PcSupplementHeadDto> page = (Page<PcSupplementHeadDto>) record;
        PageRecord<PcSupplementHeadDto> pageRecord = new PageRecord();
//        /*取出全部LotNo获取图片*/
//        List<String> lotNoList = record.stream().map(PcSupplementHeadDto::getLotNo).collect(Collectors.toList());
//        List<String> photoList=photoMapper.listPhotoByLotNoList(lotNoList);
//        System.out.println(lotNoList.size());
//        System.out.println(photoList.size());
//        for (int i = 0; i < record.size(); i++) {
//            String photo=photoList.get(i);
//            record.get(i).setPhotoPath(photo);
//        }
        /*封装返回结果*/
        pageRecord.setList(record);
        pageRecord.setTotal(page.getTotal());
        return ResponseInfo.ok(pageRecord);
    }

    @Override
    public ResponseInfo listSupplementMtl(String slipNo) {
        String userName = UserIdThread.get().getUserName();
        String companyId = UserIdThread.get().getCompanyId();
        /*判空*/
        if (slipNo.isEmpty()) {
            return ResponseInfo.error(LOGIN_CONFIG_IS_NULL.getMessage(), LOGIN_CONFIG_IS_NULL.getCode());
        }
        LambdaQueryWrapper<PcSupplementMtl> mQueryWrapper = new LambdaQueryWrapper<>();
        /*查询材料数据*/
        mQueryWrapper.eq(PcSupplementMtl::getSlipNo, slipNo);
        List<PcSupplementMtl> mtl = mtlMapper.selectList(mQueryWrapper);
        /*查询细节数据*/
        LambdaQueryWrapper<PcSupplementDetail> dQueryWrapper = new LambdaQueryWrapper<PcSupplementDetail>()
                .eq(!userName.equals(PassCompanyName),PcSupplementDetail::getCompanyId, companyId)
                .eq(PcSupplementDetail::getSlipNo, slipNo);
        List<PcSupplementDetail> details = detailMapper.selectList(dQueryWrapper);
        /*查询大底和客人号*/
        List<PcSupplementSizeDto> numberDetail = new ArrayList<>();
        if (ArrayUtils.isNoEmpyt(details)) {
            numberDetail = detailMapper.getNumberDetail(details.get(0).getLotNo(), details.get(0).getStyle());
        }
        /*补全合计和补制比例*/
        List<PcSupplementDetailDto> dtos = BeanUtil.copyList(details, PcSupplementDetailDto.class);
        for (PcSupplementDetailDto dto : dtos) {
            BigDecimal total = BigDecimal.ZERO;
            Class<? extends PcSupplementDetailDto> dtoClass = dto.getClass();
            Field[] fields = dtoClass.getDeclaredFields();
            for (Field field : fields) {
                field.setAccessible(true);
                if (field.getName().contains("lQty") || field.getName().contains("rQty")) {
                    try {
                        BigDecimal value = field.get(dto) == null ? BigDecimal.ZERO : (BigDecimal) field.get(dto);
                        total = total.add(value);
                    } catch (IllegalAccessException e) {
                        log.error("错误接口：listSupplementMtl\n错误原因：未找到对应元素：{}", field.getName());
                        return ResponseInfo.error("数据处理异常");
                    }
                }
            }
            total = total.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP);
            BigDecimal percent = total
                    .multiply(BigDecimal.valueOf(100))
                    .divide(dto.getOrdQty(), 2, RoundingMode.HALF_UP);
            dto.setTotalQty(total);
            dto.setPercent(percent);
        }
        /*封装数据*/
        Map<String, Object> map = new HashMap<>();
        map.put("numberDetail", numberDetail);
        /*提取拷贝*/
        map.put("detail", dtos);
        map.put("mtl", BeanUtil.copyList(mtl, PcSupplementMtlDto.class));
        return ResponseInfo.ok(map);
    }

    @Override
    public ResponseInfo listSupplementLot(PcSupplementDetailRequest request) {
        /*判空*/
        if (request.getMtlNo().isEmpty() || request.getSlipNo().isEmpty())
            return ResponseInfo.error(LOGIN_CONFIG_IS_NULL.getMessage(), LOGIN_CONFIG_IS_NULL.getCode());
        /*查询相应数据*/
        LambdaQueryWrapper<PcSupplementMtlLot> lQueryWrapper = new LambdaQueryWrapper<>();
        lQueryWrapper.eq(PcSupplementMtlLot::getMtlNo, request.getMtlNo())
                .eq(PcSupplementMtlLot::getSlipNo, request.getSlipNo());
        List<PcSupplementMtlLot> lot = lotMapper.selectList(lQueryWrapper);
        /*查询相应数据*/
        LambdaQueryWrapper<PcSupplementDuty> dQueryWrapper = new LambdaQueryWrapper<>();
        dQueryWrapper.eq(PcSupplementDuty::getMtlNo, request.getMtlNo())
                .eq(PcSupplementDuty::getSlipNo, request.getSlipNo());
        List<PcSupplementDuty> duty = dutyMapper.selectList(dQueryWrapper);
        /*数据封装*/
        Map<String, Object> map = new HashMap<>();
        map.put("duty", BeanUtil.copyList(duty, PcSupplementDutyDto.class));
        map.put("lot", BeanUtil.copyList(lot, PcSupplementLotDto.class));
        return ResponseInfo.ok(map);
    }

    @Override
    public ResponseInfo supFlagUpdate(SupFlagUpdateRequest request) {
        /*抽取数据*/
        String remark = request.getRemark();
        Integer flag = request.getFlag();
        List<String> slipNo = request.getSlipNo();
        if (ArrayUtils.isEmpyt(slipNo)||(StringUtils.isBlank(slipNo.get(0))&&slipNo.size()==1)){
            throw new ServiceErrorException("请先勾选数据");
        }else if (slipNo.size()>20 && flag.equals(3) && !request.getReFlag()){
            throw new ServiceErrorException("一次性退单数超过一百条");
        }
        /*检验*/
        List<PcSupplementHead> heads = lambdaQuery().
                select(PcSupplementHead::getFinanceFlag2, PcSupplementHead::getFinanceFlag, PcSupplementHead::getSlipNo)
                .in(PcSupplementHead::getSlipNo, slipNo).list();
        if (flag.equals(2)) {
            for (PcSupplementHead head : heads) {
                if (head.getFinanceFlag() != null && head.getFinanceFlag().isEmpty()) {
                    log.warn("异常接口：supFlagUpdate\n异常原因：对未审核的订单进行了取消审核操作，slipNo：{}", head.getSlipNo());
                    return ResponseInfo.error("错误订单：" + head.getSlipNo() + "\n错误原因：还没有审核，无法取消审核");
                }
                if (head.getFinanceFlag2() != null && head.getFinanceFlag2().equals("Y")) {
                    log.warn("异常接口：supFlagUpdate\n异常原因：对已被财务处理的订单进行了取消审核操作，slipNo：{}", head.getSlipNo());
                    return ResponseInfo.error("错误订单：" + head.getSlipNo() + "\n错误原因：已被财务处理，无法取消审核");
                }
            }
        }
        /*数据修改*/
        SysUserTokenDTO dto = UserIdThread.get();
        String userName = dto.getUserName();
        lambdaUpdate().eq(!userName.equals(PassCompanyName),PcSupplementHead::getCompanyId, UserIdThread.get().getCompanyId())
                .in(PcSupplementHead::getSlipNo, slipNo)
                .set(remark != null && !remark.isEmpty(), PcSupplementHead::getReturnRek, remark)
                .set(flag.equals(1), PcSupplementHead::getFinanceFlag, 'Y')
                .set(flag.equals(1), PcSupplementHead::getFinanceDate, LocalDate.now())
                .set(flag.equals(1), PcSupplementHead::getFinanceUser, userName)
                .set(flag.equals(2) ||flag.equals(3), PcSupplementHead::getFinanceFlag, null)
                .set(flag.equals(2) ||flag.equals(3), PcSupplementHead::getFinanceDate, null)
                .set(flag.equals(2) ||flag.equals(3), PcSupplementHead::getFinanceUser, null)
                .set(flag.equals(3), PcSupplementHead::getCfmFlag, null)
                .set(flag.equals(3), PcSupplementHead::getCfmDate, null)
                .set(flag.equals(3), PcSupplementHead::getCfmUser, null).update();
        return ResponseInfo.ok("修改成功");
    }

    /**
     * 补单查询作业
     * 补料单资料
     *
     * @param request
     * @return
     */
    @Override
    public ResponseInfo SupplementaryOrders(SupplementaryOrderRequest request) {
        //设置分页参数
        if (request.getPageNum() == null || request.getPageSize() == null) {
            request.setPageNum(1);
            request.setPageSize(10);
        }
        PageHelper.startPage(request.getPageNum(), request.getPageSize());
        //输入参数判断
        switch (request.getBlFlag() == null ? "" : request.getBlFlag()) {
            case "普通开补":
                request.setBlFlag("1");
                log.info("材料类型={}", request.getBlFlag());
                break;
            case "鞋面全套":
                request.setBlFlag("2");
                log.info("材料类型={}", request.getBlFlag());
                break;
            case "成型全套":
                request.setBlFlag("3");
                log.info("材料类型={}", request.getBlFlag());
                break;
            case "原材料开补":
                request.setBlFlag("4");
                log.info("材料类型={}", request.getBlFlag());
                break;
            default:
                log.info("材料类型={}-其他参数", request.getBlFlag());
                break;
        }
        //查询补料单资料
        List<PcSupplementHeadDto2> supplementaryOrderInfo = headMapper.getSupplementaryOrderInfo(request);
        for (PcSupplementHeadDto2 pcSupplementHeadDto2 : supplementaryOrderInfo) {
            if (pcSupplementHeadDto2.getBlFlag() == null) {
                continue;
            }
            switch (pcSupplementHeadDto2.getBlFlag()) {
                case "1":
                    pcSupplementHeadDto2.setBlFlag("普通开补");
                    break;
                case "2":
                    pcSupplementHeadDto2.setBlFlag("鞋面全套");
                    break;
                case "3":
                    pcSupplementHeadDto2.setBlFlag("成型全套");
                    break;
                case "4":
                    pcSupplementHeadDto2.setBlFlag("原材料开补");
                    break;
                default:
                    break;
            }
        }

        //获取total
        PageInfo list = new PageInfo(supplementaryOrderInfo);

        Map map = new HashMap();
        map.put("supplementaryOrderInfo", supplementaryOrderInfo);
        map.put("total", list.getTotal());

        return ResponseInfo.ok(map);
    }

    /**
     * 查询补制明细
     * @param slipNo
     * @return
     */
    @Override
    public ResponseInfo getSupplementaryDetails(String slipNo) {

        Map map = new HashMap();

        //查询补制明细
        List<PcSupplementDetailDto> supplementaryInfo = detailMapper.getSupplementaryInfo(slipNo);
        for (PcSupplementDetailDto dto : supplementaryInfo) {

            //查询客人号大底号
            List<PcSupplementSizeDto> numberDetail = detailMapper.getNumberDetail(dto.getLotNo(), dto.getStyle());
            map.put("numberDetail", numberDetail);
        }

        //查询补料明细
        List<PcSupplementMtlDto> materialDetail = mtlMapper.getSupplementaryMaterialDetail(slipNo);

        map.put("supplementaryInfo", supplementaryInfo);
        map.put("materialDetail", materialDetail);
        return ResponseInfo.ok(map);
    }

    @Override
    @Transactional
    public ResponseInfo supDetailDel(SupDetailRequest request) {
        String companyId = UserIdThread.get().getCompanyId();
        String userName = UserIdThread.get().getUserName();
        /*获取数据*/
        LambdaQueryWrapper<PcSupplementDetail> wrapper = new LambdaQueryWrapper<PcSupplementDetail>()
                .eq(!userName.equals(PassCompanyName),PcSupplementDetail::getCompanyId, companyId)
                .eq(PcSupplementDetail::getLotNo, request.getLotNo())
                .eq(PcSupplementDetail::getSlipNo, request.getSlipNo())
                .eq(PcSupplementDetail::getPartName, request.getPartName())
                .eq(PcSupplementDetail::getSegment, request.getSegment())
                .last("LIMIT 1");
        PcSupplementDetail detail = detailMapper.selectOne(wrapper);
        if (detail == null) {
            log.error("错误接口：supDetailDel\n错误原因：未能找到数据\n相关表：PC_SUPPLEMENT_DETAIL");
            return ResponseInfo.error("未能查到指定数据", DATA_IS_ERR.getCode());
        }
        /*获取合计*/
        BigDecimal sum;
        try {
            sum = FieldUtils.getSum(PcSupplementDetail.class, detail, "rQty", "lQty");
        } catch (IllegalAccessException e) {
            return ResponseInfo.error("数据处理异常");
        }
        /*获取材料数据*/
        List<SdBomPartNew2> partNews = partNew2Mapper.selectDelQty(companyId, detail);
        /*获取材料对应数量*/
        Map<String, Float> mtlMap = new HashMap<>();
        partNews.forEach(a -> mtlMap.put(a.getMtlColor() + a.getMtlNo(), a.getUsage() * sum.floatValue()));
        /*与补料材料表数据对比，区分需要删除和修改的数据*/
        LambdaQueryWrapper<PcSupplementMtl> mtlWrapper = new LambdaQueryWrapper<PcSupplementMtl>()
                .select(PcSupplementMtl::getMtlNo, PcSupplementMtl::getMtlColor, PcSupplementMtl::getMtlColor)
                .in(PcSupplementMtl::getMtlNo, partNews.stream().map(SdBomPartNew2::getMtlNo).collect(Collectors.toList()))
                .in(PcSupplementMtl::getMtlColor, partNews.stream().map(SdBomPartNew2::getMtlColor).collect(Collectors.toList()))
                .eq(!userName.equals(PassCompanyName),PcSupplementMtl::getCompanyId, companyId)
                .eq(PcSupplementMtl::getSlipNo, request.getSlipNo())
                .eq(PcSupplementMtl::getRemark, request.getLotNo());
        List<PcSupplementMtl> mtls = mtlMapper.selectList(mtlWrapper);
        LambdaQueryWrapper<PcSupplementDetail> detailDeleteWrapper = new LambdaQueryWrapper<PcSupplementDetail>()
                .eq(!userName.equals(PassCompanyName),PcSupplementDetail::getCompanyId, companyId)
                .eq(PcSupplementDetail::getSlipNo, request.getSlipNo())
                .eq(PcSupplementDetail::getLotNo, request.getLotNo())
                .eq(PcSupplementDetail::getPartName, request.getPartName())
                .eq(PcSupplementDetail::getSegment, request.getSegment());
        detailMapper.delete(detailDeleteWrapper);
        if (ArrayUtils.isEmpyt(mtls)) {
            return ResponseInfo.ok();
        }
        List<PcSupplementMtl> deleteMaps = new ArrayList<>();
        List<PcSupplementMtl> updateMaps = new ArrayList<>();
        mtls.forEach(a -> {
            /*判断是否有材料数据 没有则直接返回NULL*/
            Float subNumber = mtlMap.get(a.getMtlColor() + a.getMtlNo());
            float actQty = a.getActQty() == null ? 0 : a.getActQty();
            if (subNumber < actQty) {
                a.setActQty(actQty - subNumber);
                updateMaps.add(BeanUtil.copyBean(a, PcSupplementMtl.class));
            } else {
                deleteMaps.add(BeanUtil.copyBean(a, PcSupplementMtl.class));
            }
        });
        /*修改并删除材料表,责任表,指令表数据*/
        for (PcSupplementMtl updateMap : updateMaps) {
            LambdaUpdateWrapper<PcSupplementMtl> mtlUpWrapper = new LambdaUpdateWrapper<PcSupplementMtl>()
                    .eq(!userName.equals(PassCompanyName),PcSupplementMtl::getCompanyId, companyId)
                    .eq(PcSupplementMtl::getSlipNo, request.getSlipNo())
                    .eq(PcSupplementMtl::getLotNo, request.getLotNo())
                    .eq(PcSupplementMtl::getMtlNo, updateMap.getMtlNo())
                    .eq(PcSupplementMtl::getMtlColor, updateMap.getMtlColor())
                    .set(PcSupplementMtl::getActQty, updateMap.getActQty())
                    .set(PcSupplementMtl::getActQty1, updateMap.getActQty())
                    .set(PcSupplementMtl::getReqQty, updateMap.getActQty());
            mtlMapper.update(null, mtlUpWrapper);
            /*按比例更新责任数据*/
            LambdaQueryWrapper<PcSupplementDuty> dutyQueryWrapper = new LambdaQueryWrapper<PcSupplementDuty>()
                    .eq(!userName.equals(PassCompanyName),PcSupplementDuty::getCompanyId, companyId)
                    .eq(PcSupplementDuty::getSlipNo, request.getSlipNo())
                    .eq(PcSupplementDuty::getMtlNo, updateMap.getMtlNo());
            List<PcSupplementDuty> duties = dutyMapper.selectList(dutyQueryWrapper);
            BigDecimal dutySum = duties.stream().map(PcSupplementDuty::getDutyQty).reduce(BigDecimal.ZERO,BigDecimal::add);
            float dutyAcc = 0;
            for (int i = 0; i < duties.size(); i++) {
                float dutyQty;
                if (i == duties.size() - 1) {
                    dutyQty = updateMap.getActQty() - dutyAcc;
                } else {
                    BigDecimal percent =duties.get(i).getDutyQty().divide(dutySum, 2, RoundingMode.HALF_UP);
                    dutyQty = percent .multiply(BigDecimal.valueOf(updateMap.getActQty())).floatValue();
                }
                LambdaUpdateWrapper<PcSupplementDuty> dutyUpdateWrapper = new LambdaUpdateWrapper<PcSupplementDuty>()
                        .eq(!userName.equals(PassCompanyName),PcSupplementDuty::getCompanyId, companyId)
                        .eq(PcSupplementDuty::getSlipNo, request.getSlipNo())
                        .eq(PcSupplementDuty::getMtlNo, updateMap.getMtlNo())
                        .set(PcSupplementDuty::getDutyQty, dutyQty);
                dutyMapper.update(null, dutyUpdateWrapper);
            }

//            dutyMapper.updateForDel(updateMap);

            LambdaUpdateWrapper<PcSupplementMtlLot> mtlLotUpdateWrapper = new LambdaUpdateWrapper<PcSupplementMtlLot>()
                    .eq(!userName.equals(PassCompanyName),PcSupplementMtlLot::getCompanyId, companyId)
                    .eq(PcSupplementMtlLot::getSlipNo, request.getSlipNo())
                    .eq(PcSupplementMtlLot::getLotNo, request.getLotNo())
                    .eq(PcSupplementMtlLot::getMtlNo, updateMap.getMtlNo())
                    .set(PcSupplementMtlLot::getQty, updateMap.getActQty());
            lotMapper.update(null, mtlLotUpdateWrapper);
        }
        for (PcSupplementMtl deleteMap : deleteMaps) {
            LambdaQueryWrapper<PcSupplementMtl> mtlDeleteWrapper = new LambdaQueryWrapper<PcSupplementMtl>()
                    .eq(!userName.equals(PassCompanyName),PcSupplementMtl::getCompanyId, companyId)
                    .eq(PcSupplementMtl::getSlipNo, request.getSlipNo())
                    .eq(PcSupplementMtl::getRemark, request.getLotNo())
                    .eq(PcSupplementMtl::getMtlNo, deleteMap.getMtlNo())
                    .eq(PcSupplementMtl::getMtlColor, deleteMap.getMtlColor());
            mtlMapper.delete(mtlDeleteWrapper);

            LambdaQueryWrapper<PcSupplementDuty> dutyDeleteWrapper = new LambdaQueryWrapper<PcSupplementDuty>()
                    .eq(!userName.equals(PassCompanyName),PcSupplementDuty::getCompanyId, companyId)
                    .eq(PcSupplementDuty::getSlipNo, request.getSlipNo())
                    .eq(PcSupplementDuty::getLotNo, request.getLotNo())
                    .eq(PcSupplementDuty::getMtlNo, deleteMap.getMtlNo());
            dutyMapper.delete(dutyDeleteWrapper);

            LambdaQueryWrapper<PcSupplementMtlLot> mtlLotDeleteWrapper = new LambdaQueryWrapper<PcSupplementMtlLot>()
                    .eq(!userName.equals(PassCompanyName),PcSupplementMtlLot::getCompanyId, companyId)
                    .eq(PcSupplementMtlLot::getSlipNo, request.getSlipNo())
                    .eq(PcSupplementMtlLot::getLotNo, request.getLotNo())
                    .eq(PcSupplementMtlLot::getMtlNo, deleteMap.getMtlNo());
            lotMapper.delete(mtlLotDeleteWrapper);
        }
        return ResponseInfo.ok();
    }


    /**
     * 条件返回
     *
     * @return
     */
    @Override
    public ResponseInfo getDept2Type() {

        Map<String, Object> map = new HashMap();

        //查询补料部门
        List<String> dutyDeptName = headMapper.getDutyDeptName();

        //查询补料类型
        List<String> blFlag = headMapper.getBlFlag();
        for (int i = 0; i < blFlag.size(); i++) {
            switch (blFlag.get(i) == null ? "" : blFlag.get(i)) {
                case "1":
                    blFlag.set(i, "普通开补");
                    break;
                case "2":
                    blFlag.set(i, "鞋面全套");
                    break;
                case "3":
                    blFlag.set(i, "成型全套");
                    break;
                case "4":
                    blFlag.set(i, "原材料开补");
                    break;
                default:
                    break;
            }
        }

        map.put("dutyDeptName", dutyDeptName);
        map.put("blFlag", blFlag);

        return ResponseInfo.ok(map);
    }
}

